/*
 * Attribut.cpp
 *
 *  Created on: Jun 9, 2013
 *      Author: juliendubois
 */

#include "Attribut.h"

#include <chrono>
#include <random>

double Attribut::AttributArmure::absorbe(double degats, double penetration) {
	return degats - valeur + penetration;
}

void Attribut::Endurance::subit(double degats) {
	valeur -= degats;
}

double Attribut::AttributCritique::getRandValue() {
	std::normal_distribution<double> distribution(valeur,critique);
	std::default_random_engine generator(std::chrono::system_clock::now().time_since_epoch().count());

	double res;

	do {
		res = distribution(generator);
	} while (res < minAttribut || res > maxAttribut);

	return res;
}

double Attribut::PenetrationArmure::getPenetration() {
	return getRandValue();
}

bool Attribut::Esquive::esquive(double precision) {
	return getRandValue() > precision;
}

double Attribut::Force::attaque() {
	return getRandValue();
}

double Attribut::Precision::tir() {
	return getRandValue();
}
